package org.quadraspace.model;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlType;

@XmlRootElement
@XmlType(propOrder= {"board","location","sensors","interfaces"})
@Entity
public class Mote {

	@Id
	@GeneratedValue
	private Long theId;
	
	@XmlTransient
	public Long getTheId() {
		return theId;
	}
	public void setTheId(Long theId) {
		this.theId = theId;
	}

	private String id;
	
	@XmlAttribute
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}

	@OneToOne(cascade=CascadeType.ALL,fetch=FetchType.EAGER)
	private Board board = new Board();
	@XmlElement
	public Board getBoard() {
		return board;
	}
	
	public void setBoard(Board _board) {
		board = _board;
	}
	
	@OneToOne(cascade=CascadeType.ALL,fetch=FetchType.EAGER)
	private Location location = null;
	public void setLocation( Location toSet ) {
		location = toSet;
	}
	
	@XmlElement(name = "location")
	public Location getLocation() {
		return location;
	}
	
	@OneToMany(cascade=CascadeType.ALL,fetch=FetchType.EAGER)
	private Set<Interface> interfaces = new HashSet<Interface>();
	@XmlElementWrapper(name="interfaces")
	@XmlElement(name = "interface")
	public Set<Interface> getInterfaces() {
		return interfaces;
	}
	
	public void setInterfaces(Set<Interface> interfaces) {
		this.interfaces = interfaces;
	}

	@OneToMany(cascade=CascadeType.ALL,fetch=FetchType.EAGER)
	private Set<Sensor> sensors = new HashSet<Sensor>();
	@XmlElementWrapper(name="sensors")
	@XmlElement(name = "sensor")
	public Set<Sensor> getSensors() {
		return sensors;
	}

	public void setSensors(Set<Sensor> sensors) {
		this.sensors = sensors;
	}
}
